#include<iostream>
using namespace std;
int v[100];
int n,k;
void sortare_vector();
void citire_vector();
void swap(int&,int&);
int main()
{
    citire_vector();
    sortare_vector();
    if(n<k)
        cout<<"vectorul e mai mic de atat";
    else
        cout<<v[k];
    return 0;
}

void citire_vector()
{
    cout<<"cate elemente?? "<<endl;
    cin>>n;
    cout<<"introduceti elementele vectorului: ";
    for(int i=0;i<n;++i)
         cin>>v[i];
    cout<< "care element??? "<<endl;
    cin>>k;
}

void sortare_vector()
{
    // folosesc bubble sort
    for(int i=0;i<n-1;++i)
        for(int j=i+1;j<n;++j)
            if(v[i]>v[j])
                swap(v[i],v[j]);
}
void swap(int &a,int &b)
{
    int aux=a;
    a=b;
    b=aux;
}
